home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 November: Tool Chest / Dev.CD Nov 00 TC Disk 2.toast / pc / sample code / overview / dts.utilities / utilities.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-09-28  |  23.5 KB  |  548 lines

  1. /*
  2.     File:        Utilities.h
  3.  
  4.     Contains:    Collection of Utilities for DTS Sample code
  5.  
  6.     Written by:     
  7.  
  8.     Copyright:    Copyright © 1988-1999 by Apple Computer, Inc., All Rights Reserved.
  9.  
  10.                 You may incorporate this Apple sample source code into your program(s) without
  11.                 restriction. This Apple sample source code has been provided "AS IS" and the
  12.                 responsibility for its operation is yours. You are not permitted to redistribute
  13.                 this Apple sample source code as "Apple sample source code" after having made
  14.                 changes. If you're going to re-distribute the source, we require that you make
  15.                 it clear in the source that the code was descended from Apple sample source
  16.                 code, but that you've made changes.
  17.  
  18.     Change History (most recent first):
  19.                 8/18/1999    Karl Groethe    Updated for Metrowerks Codewarror Pro 2.1
  20.                 
  21.  
  22. */
  23.  
  24. #ifndef __UTILITIES__
  25. #define __UTILITIES__
  26.  
  27. #ifndef __TYPES__
  28. #include <Types.h>
  29. #endif
  30.  
  31. #ifndef __QUICKDRAW__
  32. #include <QuickDraw.h>
  33. #endif
  34.  
  35. #ifndef __DIALOGS__
  36. #include <Dialogs.h>
  37. #endif
  38.  
  39. #ifndef __FILES__
  40. #include <Files.h>
  41. #endif
  42.  
  43. #ifndef __MEMORY__
  44. #include <Memory.h>
  45. #endif
  46.  
  47. #ifndef __OSUTILS__
  48. #include <OSUtils.h>
  49. #endif
  50.  
  51. #ifndef __WINDOWS__
  52. #include <Windows.h>
  53. #endif
  54.  
  55. #ifndef __GESTALT__
  56. #include "Gestalt.h"
  57. #endif
  58.  
  59. #ifndef __FOLDERS__
  60. #include <Folders.h>
  61. #endif
  62.  
  63. #include "UtilitiesCommon.h"
  64.  
  65. /*-----------------------------------------------------------------------------------------
  66.     Global constants
  67. -----------------------------------------------------------------------------------------*/
  68.  
  69. #define    kOSEvent                app4Evt        /* event used by MultiFinder */
  70. #define    kSuspendResumeMessage    1            /* high byte of suspend/resume event message */
  71. #define    kResumeMask                1            /* bit of message field for resume vs. suspend */
  72. #define    kMouseMovedMessage        0xFA        /* high byte of mouse-moved event message */
  73. #define    kNoEvents                0            /* no events mask */
  74.  
  75. #define kDelayTime                8            /* For the delay time when flashing the
  76.                                                menubar and highlighting a button.
  77.                                                8/60ths of a second*/
  78.  
  79. #define kStartPtH                2            /* offset from the left of the screen */
  80. #define kStartPtV                2            /* offset from the top of the screen */
  81. #define kStaggerH                12            /* staggering amounts for new windows */
  82. #define kStaggerV                16
  83.  
  84. #define chBackspace                '\b'        /* ASCII code for Backspace character */
  85. #define chClear                    '\033'        /* ASCII code for Clear key (aka ESC) */
  86. #define chDown                    '\037'        /* ASCII code for down arrow */
  87. #define chEnd                    '\004'        /* ASCII code for the End key */
  88. #define chEnter                    '\003'        /* ASCII code for Enter character */
  89. #define chEscape                '\033'        /* ASCII code for Escape (aka Clear) key */
  90. #define chFunction                '\020'        /* ASCII code for any function key */
  91. #define chFwdDelete                '\177'        /* ASCII code for forward delete */
  92. #define chHelp                    '\005'        /* ASCII code for Help key */
  93. #define chHome                    '\001'        /* ASCII code for the Home key */
  94. #define chLeft                    '\034'        /* ASCII code for left arrow */
  95. #define chPageDown                '\f'        /* ASCII code for Page Down key */
  96. #define chPageUp                '\013'        /* ASCII code for Page Up key */
  97. #define chReturn                '\n'        /* ASCII code for Return character */
  98. #define chRight                    '\035'        /* ASCII code for right arrow */
  99. #define chSpace                    ' '            /* ASCII code for Space character */
  100. #define chTab                    '\t'        /* ASCII code for Tab character */
  101. #define chUp                    '\036'        /* ASCII code for up arrow */
  102.  
  103. enum { kQDOriginal = 0, kQD8Bit, kQD32Bit };    /* For use with gQDVersion */
  104.  
  105. /*-----------------------------------------------------------------------------------------
  106.     Types
  107. -----------------------------------------------------------------------------------------*/
  108.  
  109. typedef short *IntegerPtr, **IntegerHandle;
  110.  
  111. typedef long *LongintPtr, **LongintHandle;
  112.  
  113. typedef Boolean *BooleanPtr, **BooleanHandle;
  114.  
  115. typedef Rect **RectHandle;
  116.  
  117. struct    WindowTemplate    {                    /*template to a WIND resource*/
  118.     Rect    boundsRect;
  119.     short    procID;
  120.     Boolean    visible;
  121.     Boolean    filler1;
  122.     Boolean    goAwayFlag;
  123.     Boolean    filler2;
  124.     long    refCon;
  125.     Str255    title;
  126. };
  127. typedef    struct    WindowTemplate    WindowTemplate;
  128. typedef            WindowTemplate    *WindowTPtr, **WindowTHndl;
  129.  
  130. typedef Rect (*PositionWndProcPtr)(WindowPtr window, WindowPtr relatedWindow);
  131.  
  132. /*-----------------------------------------------------------------------------------------
  133.     Handy Macros/inlines
  134. -----------------------------------------------------------------------------------------*/
  135. #ifdef false                                        /* The c++ stuff is turned OFF!!! */
  136.  
  137. inline long abs(val) 
  138. {    return ((val < 0) ? (-val) : (val)); }            /* Absolute value */
  139.  
  140. inline void PStrCopy(dest, src)                        /* Pascal string copy */
  141. {    BlockMove (src, dest, (*(char *)(src))+1); }
  142.  
  143. inline Point* TopLeft(Rect& r)                        /* provide access to rect.topLeft  */
  144. {    return (Point*)(&r.top); }
  145.  
  146. inline Point* BotRight(Rect& r)                        /* provide access to rect.botRight  */
  147. {    return (Point*)(&r.bottom); }
  148.  
  149. inline void SETPT(Point *pt,short h,short v)
  150. {    (*pt).h = h; (*pt).v = v); }
  151.  
  152. inline void SETRECT(Rect *r,short left,short top,short right,short bottom)
  153. {    SETPT(TopLeft(*r), left, top); SETPT(BotRight(*r), right, bottom); }
  154.  
  155. /* 
  156.  *    Useful functions for testing gestalt attribute responses
  157.  *
  158.  *    BTstBool returns a true boolean value (0 or 1), but is slower than:
  159.  *    BTstQ which simply returns a non-zero value if the bit is set which
  160.  *    means the result could get lost if assigned to a short, for example.
  161.  *
  162.  *    arg is any integer value, bitnbr is the number of the bit to be tested.
  163.  *    bitnbr = 0 is the least significant bit.
  164.  */
  165. inline short BTstBool(arg, bitnbr)    
  166. {    return ((arg >> bitnbr) & 1); }
  167.  
  168. inline long BTstQ(arg, bitnbr)
  169. {    return (arg & (1 << bitnbr)); }
  170.  
  171. #else
  172.  
  173.  
  174. #ifndef THINK_C
  175. #define QD(whatever) (qd.##whatever)
  176. #else
  177. #define QD(whatever) (whatever)
  178. #endif
  179.  
  180.  
  181. /* define our own abs() so we don't need StdLib */
  182. #define abs(val) (((val) < 0) ? (-(val)) : (val))
  183. /* Pascal string copy */
  184. #define PStrCopy(dest, src)    (BlockMove (src, dest, (*(char *)(src))+1))
  185. #define TopLeft(r)        (* (Point *) &(r).top)
  186. #define BotRight(r)        (* (Point *) &(r).bottom)
  187. #define MIN(a, b) ((a) < (b) ? (a) : (b) )
  188. #define MAX(a, b) ((a) > (b) ? (a) : (b) )
  189. #define SETPT(pt, x, y)    (*(pt)).h = (x); (*(pt)).v = (y)
  190. #define SETRECT(r, left, top, right, bottom)    \
  191.                         SETPT(&TopLeft(*(r)), (left), (top)); \
  192.                         SETPT(&BotRight(*(r)), (right), (bottom))
  193. /* 
  194.  *    Useful macros for testing gestalt attribute responses
  195.  *
  196.  *    BTstBool returns a true boolean value (0 or 1), but is slower than:
  197.  *    BTstQ which simply returns a non-zero value if the bit is set which
  198.  *    means the result could get lost if assigned to a short, for example.
  199.  *
  200.  *    arg is any integer value, bitnbr is the number of the bit to be tested.
  201.  *    bitnbr = 0 is the least significant bit.
  202.  */
  203. #define BTstBool(arg, bitnbr)    ((arg >> bitnbr) & 1)
  204. #define BTstQ(arg, bitnbr)        (arg & (1 << bitnbr))
  205.  
  206. #endif
  207.  
  208. /*-----------------------------------------------------------------------------------------
  209.     Global variables
  210. -----------------------------------------------------------------------------------------*/
  211. /*    The following global variables are initialized by StardardInitialization to
  212.  *    define the environnment.  This used to be a single SysEnvRec, but now,
  213.  *    all those variables defined in a SysEnvRec can be returned by Gestalt
  214.  *    (except sysVRefNum; see FindSysFolder).  Note that all the variables
  215.  *    below will be correctly initialized whether Gestalt is available or not;
  216.  *    the Gestalt glue handles this.
  217.  */
  218. extern short            gMachineType;            /* which machine this is */
  219. extern short            gSystemVersion;            /* System version number */
  220. extern short            gProcessorType;            /* which CPU this is */
  221. extern Boolean            gHasFPU;                /* true if machine has an FPU */
  222. extern short            gQDVersion;                /* major QD version #; 0 for original, 
  223.                                                     1 for color QD, 2 for 32-bit QD */
  224. extern short            gKeyboardType;            /* which type of keyboard is present */
  225. extern short            gAppleTalkVersion;        /* AppleTalk version number */
  226.         
  227. /*    These are also handled by Gestalt. gHasPMMU has no corresponding SysEnvRec
  228.  *    field, but it is handled by the glue, so we include it here for completeness.
  229.  *    gAUXVersion will be initialized with Gestalt if present, but correctly
  230.  *    set even if Gestalt is not available
  231.  */
  232. extern Boolean            gHasPMMU;                /* true if machine has a PMMU or equivalent */
  233. extern short            gAUXVersion;            /* major A/UX version number (0 if not present) */
  234.  
  235. /*    
  236.  *    gHasWaitNextEvent is set to TRUE if the Macintosh we are running on has
  237.  *    WaitNextEvent implemented. We can use this in our main event loop to
  238.  *    determine whether to call WaitNextEvent or GetNextEvent.
  239.  */
  240. extern Boolean            gHasWaitNextEvent;
  241.  
  242. /*
  243.  *    gAppResRef is the application’s resource file reference. I need to save
  244.  *    this since I can open other resource files. The current resource file is
  245.  *    always gAppResRef unless I momentarily set it to another file to read its
  246.  *    resources, and then immediately restore it back.
  247.  */
  248. extern short            gAppResRef;
  249.  
  250. /*
  251.  *    gInBackground is maintained by our osEvent handling routines. Any part of
  252.  *    the program can check it to find out if it is currently in the background.
  253.  */
  254. extern Boolean            gInBackground;            /* maintained by StandardInitialization
  255.                                                       and DoEvent */
  256.                                                       
  257. /*
  258.  *    gAppName holds the name of the application that's running. You can use if
  259.  *    for any purpose you'd like. It is also used by StandardAbout if it can't
  260.  *    find a string to use for the application name in a resource, so make sure
  261.  *    you call InitForStandardAbout if you are going to call StandardAbout. If you
  262.  *    call StandardInitialization, this is done for you.
  263.  */
  264. extern Str255            gAppName;
  265.  
  266. /*
  267.  *    gSignature holds the creator signature for the running application. It follows the
  268.  *    same rules as those for gAppName.
  269.  */
  270. extern OSType            gSignature;
  271.  
  272. /*
  273.  *    Initial values of these global variables are set to zero or FALSE by MPW's 
  274.  *    runtime initialization routines.  If the Utilities initialization routines
  275.  *    have been properly called, then gUtilitiesInited will be true.  If it is
  276.  *    not true, then the values of the above global variables are invalid.
  277.  */
  278. extern Boolean            gUtilitiesInited;
  279.  
  280. /*-----------------------------------------------------------------------------------------
  281.     Interface to routines
  282. -----------------------------------------------------------------------------------------*/
  283.  
  284. #ifdef __cplusplus
  285. extern "C" {
  286. #endif
  287.  
  288. short        CenteredAlert(short alertID, WindowPtr relWindow);
  289.             /* Given an Alert ID and a related window pointer, this routine will center
  290.                the alert on the same device as the related window.  If the related
  291.                window pointer is NULL, then the alert will be centered on the device
  292.                that the alert would normally be placed if Alert was called directly. */
  293.  
  294. void        CenterRectInRect(Rect outerRect, Rect *innerRect);
  295.             /* Given two rectangles, this routine centers the second one within the first. */
  296.  
  297. Rect        CenterWindow(WindowPtr window, WindowPtr relatedWindow);
  298.             /* Given a window pointer and a related window pointer, this routine will
  299.                center the window on the same device as the related window.  If the
  300.                related window pointer is NULL, then the window will be centered on the
  301.                device that the window already is.
  302.                WARNING: This routine may move or purge memory. */
  303.  
  304. void        CloseAnyWindow(WindowPtr window);
  305.             /* Closes the indicated window.  Does the right thing, taking into account
  306.                that the window may belong to a DA.
  307.                WARNING: An application window is closed via a CloseWindow call.  Use
  308.                            this call when you want to keep the storage for the window
  309.                         record.  (Compare against DisposeAnyWindow.) */
  310.  
  311. void        DisposeAnyWindow(WindowPtr window);
  312.             /* Disposes of the indicated window.  Does the right thing, taking into account
  313.                that the window may belong to a DA.
  314.                WARNING: An application window is closed via a DisposeWindow call.  Use
  315.                            this call when you want to free up the storage for the window
  316.                         record.  (Compare against CloseAnyWindow.) */
  317.  
  318. void        DeathAlert(short errResID, short errStringIndex);
  319.             /* Display an alert that tells the user an error occurred, then exit the
  320.                program. This routine is used as an ultimate bail-out for serious errors
  321.                that prohibit the continuation of the application. */ 
  322.  
  323. void        DeathAlertMessage(short errResID, short errStringIndex, short message);
  324.  
  325. void        ErrorAlert(short errResID, short errStringIndex);
  326.  
  327. void        ErrorAlertMessage(short errResID, short errStringIndex, short message);
  328.  
  329. OSErr        FindSysFolder(short *foundVRefNum, long *foundDirID);
  330.             /* FindSysFolder returns the (real) vRefNum, and the DirID of the current
  331.                system folder.  It uses the Folder Manager if present, otherwise
  332.                it falls back to SysEnvirons.  It returns zero on success, otherwise
  333.                a standard system error. */
  334.  
  335. Handle        GetAppIndResource(ResType theType, short index, OSErr *err);
  336.             /* GetAppIndResource gets a resource from the application's res file by index */
  337.  
  338. Handle        GetAppNamedResource(ResType theType, Str255 name, OSErr *err);
  339.             /* GetAppNamedResource gets a resource from the application's res file by name */
  340.  
  341. Handle        GetAppResource(ResType theType, short theID, OSErr *err);
  342.             /* GetAppResource gets a resource from the application's res file by resource ID */
  343.  
  344. short        GetAUXVersion( void);
  345.             /* getAUXVersion -- Checks for the presence of A/UX by whatever means is
  346.                appropriate.  Returns the major version number of A/UX (i.e. 0 if A/UX 
  347.                is not present, 1 for any 1.x.x version 2 for any 2.x version, etc.
  348.                This code should work for all past, present and future A/UX systems. */
  349.  
  350. DialogPtr    GetCenteredDialog(short id, DialogPtr storage, WindowPtr relatedWindow, WindowPtr behind);
  351.             /* Given a dialog ID and a related window pointer, this routine will center
  352.                the dialog on the same device as the related window.  If the related
  353.                window pointer is NULL, then the dialog will be centered on the device
  354.                that the dialog would normally be placed if GetNewDialog was called. */
  355.  
  356. WindowPtr    GetCenteredWindow(short id, Ptr storage, WindowPtr relWindow, WindowPtr behind, Boolean inColor);
  357.             /* Given a window ID and a related window pointer, this routine will center
  358.                the window on the same device as the related window.  If the related
  359.                window pointer is NULL, then the window will be centered on the device
  360.                that the window would normally be placed if GetNewWindow was called. */
  361.  
  362. Boolean     GetCheckOrRadio(DialogPtr dlgPtr, short itemNo);
  363.  
  364. long        GetGestaltResult(OSType gestaltSelector);
  365.             /* GetGestaltResult returns the result value from Gestalt for the specified
  366.                selector.  If Gestalt returned an error GetGestaltResult returns zero.  Use 
  367.                of this function is only cool if we don't care whether Gestalt returned an 
  368.                error.  In many casesyou may need to know the exact Gestalt error code so 
  369.                then this routine would be inappropriate. */
  370.  
  371. Point        GetGlobalMouse(void);
  372.             /* Returns the location of the mouse in local coordinates. It does this by
  373.                calling OSEventAvail(). */ 
  374.  
  375. Point        GetGlobalTopLeft(WindowPtr window);
  376.             /*     Given a window, this will return the top left point of the window’s port in
  377.                   global coordinates. Something this doesn’t include, is the window’s drag
  378.                   region (or title bar). This returns the top left point of the window’s
  379.                   content area only. */
  380.  
  381. long        GetKFreeSpace(short vRefNum);
  382.  
  383. Rect        GetMainScreenRect(void);
  384.  
  385. GDHandle    GetRectDevice(Rect globalRect);
  386.             /* Find the greatest overlap device for the given global rectangle. */
  387.  
  388. Rect        GetRectDeviceRect(Rect globalRect);
  389.             /* Find the rect of the greatest overlap device for the given global rect. */
  390.  
  391. WindowPtr    GetSomeKindOfWindow(PositionWndProcPtr whatKind, short windID, Ptr storage, WindowPtr relWindow, WindowPtr behind, Boolean inColor);
  392.             /* Given a window positioning procedure pointer, a window ID and a window
  393.                pointer the window relates to, this function open a new window by either
  394.                a NewCWindow or a NewWindow call, depending on the value of inColor.  The
  395.                window will be opened invisible, independent of what the resource says.
  396.                Once the window is opened successfully, the positioning procedure is
  397.                called.  The positioning procedure is passed a pointer to the just-opened
  398.                invisible window and a pointer to the related window.  It is up to the
  399.                positioning procedure to move the invisible window to the correct location
  400.                on the correct device.  Once the positioning procedure returns, the window
  401.                will be made visible if so indicated by the resource. */
  402.  
  403. WindowPtr    GetStaggeredWindow(short id, Ptr storage, WindowPtr relWindow, WindowPtr behind, Boolean inColor);
  404.             /* Given a window ID and a window pointer the window relates to, this function
  405.                will stagger the window’s rectangle before showing it on the proper screen.
  406.                This follows the Apple Human Interface Guidelines for where to place a
  407.                staggered window on the screen.  If the window is not closely associated
  408.                with another window, pass a NULL for the window pointer of the related
  409.                window.  If you pass a NULL, the window is simply displayed where the
  410.                resource would indicate. */
  411.  
  412. TrapType    GetTrapType(short theTrap);
  413.             /* Returns the type (OSType or ToolType) of the trap. It does this by checking
  414.                the bits of the trap word. */ 
  415.  
  416. Rect        GetWindowContentRect(WindowPtr window);
  417.             /* Given a window pointer, return the global rectangle that encloses the
  418.                content area of the window. */
  419.  
  420. short        GetWindowCount(Boolean includeDAs, Boolean includeInvisibles);
  421.             /* This procedure counts the number of windows in the application plane.  You have the
  422.                choices of also including DAs and invisible windows in this count. */
  423.  
  424. GDHandle    GetWindowDevice(WindowPtr window);
  425.             /* Find the greatest overlap device for the given window. */
  426.  
  427. Rect        GetWindowDeviceRect(WindowPtr window);
  428.             /* Given a window pointer, find the device that contains most of the window
  429.                and return the device's bounding rectangle. */
  430.  
  431. Rect        GetWindowDeviceRectNMB(WindowPtr window);
  432.             /* Given a window pointer, find the device that contains most of the window
  433.                and return the device's bounding rectangle.  If this device is the main
  434.                device, then remove the menubar area from the rectangle. */
  435.  
  436. Rect        GetWindowStructureRect(WindowPtr window);
  437.             /* This procedure is used to get the rectangle that surrounds the entire
  438.                structure of a window.  This is true whether or not the window is visible.
  439.                If the window is visible, then it is a simple matter of using the bounding
  440.                rectangle of the structure region.  If the window is invisible, then the
  441.                strucRgn is not correct.  To make it correct, then window has to be moved
  442.                way off the screen and then made visible.  This generates a valid strucRgn,
  443.                although it is valid for the position that is way off the screen.  It still
  444.                needs to be offset back into the original position.  Once the bounding
  445.                rectangle for the strucRgn is obtained, the window can then be hidden again
  446.                and moved back to its correct location.  Note that ShowHide is used,
  447.                instead of ShowWindow and HideWindow.  HideWindow can change the plane of
  448.                the window.  Also, ShowHide does not affect the hiliting of windows. */
  449.   
  450. void        GlobalToLocalRect(Rect *aRect);
  451.  
  452. void        InitToolBox(void);
  453.  
  454. void        InitUtilities(void);
  455.             /* This sets up some global variables for use by the utilities package.  If you call
  456.                StandardInitialization, you don't need to call this, as it will do it for you. */ 
  457.  
  458. Boolean        IsAppWindow(WindowPtr window);
  459.             /* Returns TRUE if the windowKind of the window is greater than or equal to
  460.                userKind. If it is less, or the window is NIL, then return FALSE. */ 
  461.  
  462. Boolean        IsDAWindow(WindowPtr window);
  463.             /* Returns TRUE if the windowKind of the window is less than zero. If not, or
  464.                the window is NIL, then return FALSE. */ 
  465.  
  466. void        LocalToGlobalRect(Rect *aRect);
  467.  
  468. char        LockHandleHigh(Handle theHandle);
  469.             /* Does a MoveHHi on the handle and then locks it.  Also, the original state
  470.                of the handle is returned, so you can keep it and set the handle back to it's
  471.                original state with a HSetState call. */
  472.  
  473. short        NumToolboxTraps(void);
  474.             /* Determines the size of the Tool trap table. It does this by sampling a
  475.                couple of trap locations and seeing which, if any are Unimplemented. */ 
  476.  
  477. void        OutlineControl(ControlHandle button);
  478.  
  479. void         OutlineDialogItem(DialogPtr dlgPtr, short item);
  480.  
  481. void        PositionRectInRect(Rect outerRect, Rect *innerRect, Fixed horzRatio, Fixed vertRatio);
  482.             /* Given two rectangles, this routine positions the second within the first one
  483.                so that the it maintains the spacing specified the the horzRatio and vertRatio
  484.                parameters. In other words, to center an inner rectangle hoizontally, but
  485.                have its center be 1/3 from the top of the outer rectangle, call this
  486.                routine with horzRatio = FixRatio(1, 2), vertRatio = FixRatio(1, 3). */
  487.  
  488. void        PullApplicationToFront(void);
  489.             
  490. void        PStrConcat(Str255 targetStr, Str255 appendStr);
  491.             /* Concatenate a Pascal string onto another. */
  492.  
  493. void        SelectButton(ControlHandle button);
  494.             /* Given the button control handle, this will cause the button to look as if it
  495.                has been clicked in. This is nice to do for the user if they type return or
  496.                enter to select the default item. */
  497.  
  498. void        SetCheckOrRadioButton(DialogPtr dlgPtr, short itemNo, short state);
  499.  
  500. Rect        StaggerWindow(WindowPtr window, WindowPtr relatedWindow);
  501.             /* This algorithm for staggering windows does quite a good job.  It also is
  502.                quite gnarly.  Here's the deal:
  503.                There are pre-designated positions that we will try when positioning a
  504.                window.  These slots will be tried from the upper-left corner towards the
  505.                lower-right corner.  If there are other windows in that slot, then we will
  506.                consider that slot taken, and proceed to the next slot.  A slot is
  507.                determined to be taken by checking a point with a slop area.  This slop
  508.                area is diamond-shaped, not simply rectangular.  If there is no other
  509.                visible window with an upper-left corner within the slopt diamond, then
  510.                we are allowed to position our window there.
  511.                The above rule holds true unless this forces the window to be partly
  512.                off the screen.  If the window ends up partly off the screen, then we give
  513.                up and just put it in the first slot. */
  514.  
  515. void        StandardAbout(short appNameStringID);
  516.             /* Shows a standard about box with the name of the application, its version
  517.                number, a copyright notice, and DTS credits. Most of this information is
  518.                taking from a standard DITL and the application’s 'vers' resource. The name
  519.                of the application is taken either from the 'STR ' resource passed in to
  520.                this routine, or from GetAppParms() if that resource doesn’t exist, or you
  521.                pass in -1. */ 
  522.  
  523. void        StandardInitialization(short callsToMoreMasters);
  524.             /* Initializes “gInBackGround” to FALSE. Makes the following InitXXX calls:
  525.                InitGraf(), InitFonts(), InitWindows(), InitMenus(), TEInit(),
  526.                InitDialogs(), InitCursor(). Brings application to front with 3 EventAvail
  527.                calls. Calls SysEnvirons to initialize “gMac”. Calls TrapExists() to
  528.                initialize “gHasWaitNextEvent”. */ 
  529.    
  530. void        StandardMenuSetup(short MBARID, short AppleMenuID);
  531.             /* Installs and draws the menus indicated by 'MBAR'(MBARID). Adds DA’s to the
  532.                menu indicated by AppleMenuID by calling AddResMenu. If the menuBar cannot
  533.                be created, the alert specified by rDeathAlert is displayed. */   
  534.  
  535. void         ToggleCheck(DialogPtr dlgPtr, short cChkItem);
  536.  
  537. Boolean        TrapExists(short theTrap);
  538.             /* Returns TRUE if the trap exists (i.e., it’s callable without getting DS
  539.                error 12) */ 
  540.  
  541. void        ZoomToWindowDevice(WindowPtr window, short maxWidth, short maxHeight,
  542.                                short zoomDir, Boolean front);
  543.  
  544. #ifdef __cplusplus
  545. }
  546. #endif
  547.  
  548. #endif